#pragma once

#include <string_view>
#include <string>
#include <ostream>
#include <sstream>

namespace http
{

class ContentType
{
public:
    ContentType(const std::string_view &str)
        : str_(str) {}

    ContentType(const std::string_view &first, const std::string_view &second)
        : str_(std::string(first) + "/" + std::string(second)) {}

    virtual ~ContentType() {}

    static const ContentType &fromExt(const std::string_view &ext);

    std::string str() const {
        std::ostringstream ss;
        ss << *this;
        return ss.str();
    }

private:
    std::string str_;

    friend std::ostream &operator<<(std::ostream &out, const ContentType &type) {
        out << type.str_;
        return out;
    }
};

} // namespace http
